﻿using System.Collections.Generic;
using System.ComponentModel;
using Newtonsoft.Json;

namespace Hourglass.Qrobot.Models
{
    public sealed class ReturnedGroupInfo
    {
        /// <summary>
        /// 群组信息
        /// </summary>
        [JsonProperty("ginfo")]
        public Info GroupInfo { get; set; }

        /// <summary>
        /// 成员信息
        /// </summary>
        [JsonProperty("minfo")]
        public List<MemberInfo> MemberInfos { get; set; }

        /// <summary>
        /// 成员备注
        /// </summary>
        [JsonProperty("cards")]
        public List<MemberMark> MemberMarks { get; set; }

        /// <summary>
        /// 成员VIP信息
        /// </summary>
        [JsonProperty("vipinfo")]
        public List<VipInfo> VipInfos { get; set; }

        /// <summary>
        /// 成员在线信息
        /// </summary>
        [JsonProperty("stats")]
        public List<OnlineInfo> OnlineInfos { get; set; }

        #region Internal Class

        /// <summary>
        /// 成员标志
        /// </summary>
        public sealed class Member
        {
            /// <summary>
            /// 成员用户ID
            /// </summary>
            [JsonProperty("muin")]
            public long MemberUin { get; set; }

            /// <summary>
            /// 内容未知
            /// </summary>
            [JsonProperty("mflag")]
            public long Flag { get; set; }
        }

        /// <summary>
        /// 成员信息
        /// </summary>
        public sealed class MemberInfo
        {
            /// <summary>
            /// 用户ID
            /// </summary>
            [JsonProperty("uin")]
            public long Uin { get; set; }

            /// <summary>
            /// 昵称
            /// </summary>
            [JsonProperty("nick")]
            public string NickName { get; set; }

            /// <summary>
            /// 性别[male/female]
            /// </summary>
            [JsonProperty("gender")]
            public string Gender { get; set; }

            /// <summary>
            /// 国家
            /// </summary>
            [JsonProperty("country")]
            public string Country { get; set; }

            /// <summary>
            /// 省份
            /// </summary>
            [JsonProperty("province")]
            public string Province { get; set; }

            /// <summary>
            /// 城市
            /// </summary>
            [JsonProperty("city")]
            public string City { get; set; }
        }

        /// <summary>
        /// 成员备注名称
        /// </summary>
        public sealed class MemberMark
        {
            /// <summary>
            /// 成员用户ID
            /// </summary>
            [JsonProperty("muin")]
            public long MemberId { get; set; }

            /// <summary>
            /// 备注名称
            /// </summary>
            [JsonProperty("card")]
            public string MarkName { get; set; }
        }

        public sealed class OnlineInfo
        {
            /// <summary>
            /// 成员用户ID
            /// </summary>
            [JsonProperty("uin")]
            public long Uin { get; set; }

            /// <summary>
            /// 登录类型[PC/...]
            /// </summary>
            [DefaultValue(0)]
            [JsonProperty("client_type")]
            public int ClientType { get; set; }

            /// <summary>
            /// 在线状态[繁忙/...]
            /// </summary>
            [DefaultValue(20)]
            [JsonProperty("stat")]
            public int Status { get; set; }
        }

        /// <summary>
        /// 成员VIP信息
        /// </summary>
        public sealed class VipInfo : ReturnedUserFriends.VipInfo { }

        /// <summary>
        /// 群组信息
        /// </summary>
        public sealed class Info
        {
            [JsonProperty("gid")]
            public long GroupId { get; set; }

            [JsonProperty("name")]
            public string Name { get; set; }

            [JsonProperty("code")]
            public long Code { get; set; }

            /// <summary>
            /// 群等级
            /// </summary>
            [JsonProperty("level")]
            public int Level { get; set; }

            [JsonProperty("class")]
            public long Class { get; set; }

            /// <summary>
            /// 公告
            /// </summary>
            [JsonProperty("memo")]
            public string Memo { get; set; }

            /// <summary>
            /// 群主QQ号
            /// </summary>
            [JsonProperty("owner")]
            public long OwnerQq { get; set; }

            /// <summary>
            /// 创建时间的秒数
            /// </summary>
            [JsonProperty("createtime")]
            public long CreateTime { get; set; }

            [JsonProperty("option")]
            public int Option { get; set; }

            [JsonProperty("face")]
            public int Face { get; set; }

            [JsonProperty("flag")]
            public long Flag { get; set; }

            [JsonProperty("fingermemo")]
            public string Fingermemo { get; set; }

            [JsonProperty("members")]
            public List<Member> Members { get; set; }
        }

        #endregion Internal Class
    }
}
